<?php

namespace app\controller\admin;

use app\BaseController;
use app\repositories\DefaultModel\admin\AdminRepository;
use think\facade\Db;


class ConfigController extends BaseController
{

    public function apiConfig()
    {
        $res = Db::name("config")->select();
        foreach ($res as $key => $row) {
            if ($row['image']) {
                $arr[$row['title']] = $row['image'];
                continue;
            }
            if ($row['content']) {
                $arr[$row['title']] = $row['content'];
            }
        }
       return  retJson($arr);
    }

    public function getList()
    {
        $result = Db::name("config")->select();
        return retJson(['list' => $result]);
    }
    public function doEdit()
    {
        $result = input("");

        $list = $result['list'];
        Db::name("config")->where("1=1")->delete();
        Db::name("config")->insertAll($list);

        return retJson();
    }


}
